﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache">  <!-- HTTP 1.1 -->
    <meta http-equiv="cache-control" content="no-cache,must-revalidate">  <!-- HTTP 1.0 -->
    <meta name="renderer" content="webkit|ie-comp|ie-stand" /> <!--优先级：极速模式，兼容模式，IE模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title>扬州房产测绘业务管理系统</title>
    <link rel="stylesheet" type="text/css" href="../../libs/jeasyui-181/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../libs/jeasyui-181/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../libs/jeasyui-181/themes/color.css">
    <link rel="stylesheet" type="text/css" href="../../css/common.css">
    <script type="text/javascript" src="../../libs/jeasyui-181/jquery.min.js"></script>
    <script type="text/javascript" src="../../libs/jeasyui-181/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../libs/thUtil.js"></script>
    <script type="text/javascript">

        var mainGrid = new UserContol();
        var addDay = -3;
        $(function () {
            if (UrlParm.hasParm('text')) {
                $('h1').html(UrlParm.parm('text'));
            }

            //预设显示三天内的日期
            var date = new Date();
            var startTime = Tools.date.addDay(new Date(), addDay);
            var endTime = Tools.date.addDay(new Date(), 0);

            $('#startTime').datebox('setValue', startTime);
            $('#endTime').datebox('setValue', endTime);

            $('#dd').datebox({
                required: true
            });
            $('#search_Link').html(button.search).linkbutton({ onClick: mygrid.reload });

            //重置
            $('#reset_Link').html(button.reset).click(ajax.reset);

            mygrid.init();
        });

        var ajax = {
            reset: function () {
                $('#loginName').textbox('clear');
                var date = new Date();
                var startTime = Tools.date.addDay(new Date(), addDay);
                var endTime = Tools.date.addDay(new Date(), 0);

                $('#startTime').datebox('setValue', startTime);
                $('#endTime').datebox('setValue', endTime);
            },
            getList: function (param, success) {

                if ($('#loginName').textbox('getValue') != '') {
                    param.loginName = window.parent.$('#loginName').textbox('getValue');
                }
                if ($('#startTime').datebox('getValue') != '') {
                    param.startTime = $('#startTime').datebox('getValue');
                }
                if ($('#endTime').datebox('getValue') != '') {
                    param.endTime = $('#endTime').datebox('getValue') + ' 23:59:59';
                }


                Network.connect(window.api.eventLogSelectPageList, 'POST', param, function (res) {
                    console.log(res);
                    if (res.code == ResponseCode.OK) {
                        success(res.data);
                        console.log(res.data);
                    }
                });
            },
            getOne: function (param, success) {
                Network.connect(window.api.applicationsSelectOne, 'POST', param, function (res) {
                    if (res.code == ResponseCode.OK) {
                        success(res.data);
                    }
                });
            },
            insert: function () {
                dlg = window.parent.$.hDialog({
                    href: window.router.applicationsForm + '?n=' + Math.random(),
                    title: '新增栏目',
                    width: 700,
                    height: 350,
                    onLoad: function () {
                        var row = mygrid.selectRow();

                      window.parent.$("tr[name='edit']").hide();
                    },
                    submit: function () {
                        var isValid = window.parent.$('#form').form("validate");
                        if (isValid) {

                            var formData = window.parent.$("#form").serializeJson();

                            Network.connect(window.api.applicationsInsert, 'POST', formData, function (res) {
                                if (res.code == ResponseCode.OK) {
                                    Tools.alert('添加成功');
                                    dlg.dialog('close');
                                    mygrid.reload();
                                }
                            });
                        }
                    }
                });
            },
            update: function () {
                var rows = $('#mainGrid').datagrid("getSelections");
                if (rows.length == 0) {
                    Tools.alert('请选择需要修改的数据。'); return;
                }
                dlg = window.parent.$.hDialog({
                    href: window.router.applicationsForm + '?n=' + Math.random(),
                    title: '修改栏目',
                    width: 700,
                    height: 350,
                    onLoad: function () {
                        var param = { APPLICATIONID: rows[0].APPLICATIONID };
                        ajax.getOne(param, function (data) {
                            console.log(data);
                          window.parent.$('#form').form('load', data);
                        });

                      window.parent.$("tr[name='edit']").hide();
                    },
                    submit: function () {
                        var isValid = window.parent.$('#form').form("validate");
                        if (isValid) {
                            var formData = window.parent.$("#form").serializeJson();
                            Network.connect(window.api.applicationsUpdate, 'POST', formData, function (res) {
                                if (res.code == ResponseCode.OK) {
                                    Tools.alert('添加成功');
                                    dlg.dialog('close');
                                    mygrid.reload();
                                }
                            });
                        }
                    }
                });
            },
            delete: function () {
                var rows = $('#mainGrid').datagrid("getSelections");
                if (rows.length == 1) {
                    Tools.confirm('是否确定删除该数据？', function (result) {
                        if (result) {
                            var formData = { APPLICATIONID: rows[0].APPLICATIONID };
                            Network.connect(window.api.applicationsDelete, 'POST', formData, function (res) {
                                if (res.code == ResponseCode.OK) {
                                    Tools.alert('删除成功');
                                    mygrid.reload();
                                }
                            });
                        }
                    });
                }
                else {
                    Tools.alert('请选择需要删除的数据。');
                }
            }
        }

        var mygrid = {
            init: function () {
                mainGrid.dataGrid.id = 'mainGrid';
                mainGrid.dataGrid.idField = 'ID';
                mainGrid.dataGrid.sortName = 'CREATETIME';
                mainGrid.dataGrid.sortOrder = 'asc';
                mainGrid.dataGrid.toolbar = '#toolbar';
                mainGrid.dataGrid.onLoadSuccess = function (data) {
                    if (data.total == 0)
                        setEmptyData($(this));
                };
                mainGrid.dataGrid.loader = function (param, success, error) {
                    $('#mainGrid').datagrid('clearSelections');
                    ajax.getList(param, success);
                };
                mainGrid.dataGrid.columns = [[
                    //{ field: 'USERID', title: '用户编号', halign: 'center', align: 'center', width: 120 },
                    { field: 'LOGINNAME', title: '登录账号', halign: 'center', align: 'left', width: 120, sortable: true },
                    { field: 'IP', title: '客户端IP', halign: 'center', align: 'center', width: 120, sortable: true },
                    { field: 'RESTNAME', title: '调用完整路径', halign: 'center', align: 'left', width: 260 },
                    { field: 'RESULT', title: '调用结果', halign: 'center', align: 'left', width: 500 },
                    { field: 'CREATETIME', title: '操作时间', halign: 'center', align: 'center', width: 180, sortable: true }
                ]];
                mainGrid.InitdataGrid();
            },
            reload: function () {
                $('#mainGrid').datagrid('reload');//$('#mainGrid').datagrid('clearSelections').datagrid('reload');
            },
            selectRow: function () {
                return $('#mainGrid').datagrid('getSelected');
            }
        };

    </script>

</head>
<body>
    <div class="container-wrap">
        <div id="toolbar">
            <div class="container-tit">
                <h1></h1>
            </div>
            <div class="sreach fixed">
                <div class="input-box">
                    <input type="text" id="loginName" name="loginName" class="easyui-textbox" data-options="label:'登录账号:',labelWidth: 80,width:240," />
                </div>
                <span class="time-box">
                    <input type="text" id="startTime" name="startTime" class="easyui-datebox" validtype='date' data-options="label:'操作日期:',labelWidth: 80,width:200,formatter:myformatter,parser:myparser" />
                    <input type="text" id="endTime" name="endTime" class="easyui-datebox" validtype='date' data-options="label:'~',labelWidth: 20,width:200,formatter:myformatter,parser:myparser" />
                </span>

                <a id="search_Link" href="#" class="easyui-linkbutton search">查询</a>
                <a id="reset_Link" href="#" class="easyui-linkbutton default">重置</a>
                <div class="bar-btn">

                </div>

            </div>
        </div>
        <div id="mainGrid"></div>
    </div>
</body>
</html>